#include "../game_server.cpp"
#include "../room.cpp"
#include "../user.cpp"
#include "../protocol_dist.hpp"
#include "ws_websocket.hpp"
#include <iostream>

using namespace std;
using namespace winux;
FASTDO_API void ActionMain(ProtocolC2SRegUser *msg, pWsReqCtx ctx, GameServer &game)
{
    ProtocolS2CRegUser rtn;
    User* user = game.newUser();

    user->sessionTime = (int)GetUtcTime();
    user->token = winux::MD5(winux::Format("%llu", (int)winux::GetUtcTimeMs())).toString();
    rtn.user->sessionTime = user->sessionTime;
    rtn.user->token = user->token;
    user->login(ctx);

    rtn.ok = true;
    ctx->send(ws::OpCode::dataText, false, rtn.toMixed().json());
}